const http = require('http')
const url = require('url')
// console.log(url);

const server = http.createServer((req, res) => {
  var urlString = req.url
  var urlObj = url.parse(urlString, true)
  switch (urlObj.pathname) {
    case '/api':
      res.write(`${urlObj.query.collback}('hello')`)
      break
    default:
      res.write('404, not found page!')
      break
  }
  res.end()
})

server.listen('5000', () => {
  console.log('5000 端口的服务器以启动');
})